// author: shelman
// description：TCP和UDP通信工具模块公共数据和接口定义
#pragma once

#include <string>
#include <memory>
#include <functional>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>


#if defined(_WIN32) || defined(_WIN64)
#define NetworkUtil_DllExport __declspec(dllexport)
#else
#define NetworkUtil_DllExport __attribute__((visibility("default")))
#endif  // _WIN32


namespace NetworkUtil {

struct ConnectionConfigInfo
{
    bool bAsync = false; // 异步标志，true -- 异步，false -- 阻塞
    bool bAutoReconn = false; // 自动重连标志，true -- 自动重连，false -- 不自动重连
    std::string strSrvIP = ""; // 作为客户端时，填写服务端的IP
    uint16_t ui16SrvPort = 0; // 作为客户端时，填写服务端的Port
    uint16_t ui16LocalPort = 0; // 本地Port，作为服务端时，服务端有效的Port
    uint32_t ui32BufMaxSize = 64 * 1024; // 数据接收的最大缓存，单位字节（Byte）

    ConnectionConfigInfo() {}

    ConnectionConfigInfo(bool async, bool autoReconn
                         , std::string srvIP, uint16_t srvPort
                         , uint16_t localPort, uint32_t bufMaxSize)
    {
        bAsync = async;
        bAutoReconn = autoReconn;
        strSrvIP = srvIP;
        ui16SrvPort = srvPort;
        ui16LocalPort = localPort;
        ui32BufMaxSize = bufMaxSize;
    }
};

} // namespace NetworkUtil
